#include <iostream>
#include <vector>
using namespace std;

int main() 
{
    int n = 0, q = 0;
    cin >> n >> q;
    vector<int> v1(n + 1);
    for(int i = 1; i <= n; i++)
    {
        cin >> v1[i];
    }
    vector<long long> dp(n + 1);
    for(int i = 1; i <= n; i++)
    {
        dp[i] = dp[i - 1] + v1[i];
    }
    int l = 0 , r = 0;
    while(q--)
    {
        cin >> l >> r;
        cout << dp[r] - dp[l - 1] << endl;
    }
    return 0;
}
